package com.yonyou.pmclouds.project.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.util.CommonProgramConsts;
import com.yonyou.pmclouds.plan.entity.ProjectPlanViewVO;
import com.yonyou.pmclouds.projectstatus.entity.ProjectStatusVO;
import com.yonyou.pmclouds.projecttype.entity.ProjectTypeVO;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Table(name = "pmbd_project")
public class ProjectVO extends SuperVO {
    public static final String PK_PROJECT = "pkProject";
    public static final String MANAGER = "manager";
    public static final String MANAGER_NAME = "managerName";
    public static final String APPROVAL_DATE = "approvalDate";
    public static final String END_DATE = "endDate";
    public static final String DESCRIPTION = "description";
    public static final String PROJECT_STATE = "projectState";
    public static final String SNAME = "sname";
    public static final String SCODE = "scode";
    public static final String ISKEY = "iskey";
    public static final String PK_ORG = "pkOrg";
    public static final String SRCTYPE = "srcType";
    public static final String PK_SRC = "pkSrc";
    public static final String MANAGERMOBILE = "managerMobile";
    public static final String CREATORMOBILE = "creatorMobile";
    public static final String PROJECT_TYPE = "pkProjectType";
    public static final String PROJECT_STATUS = "pkProjectStatus";
    public static final String PROJECT_TYPE_CLOUD_VO = "projectTypeCloudVO";
    public static final String PROJECT_STATE_CLOUD_VO = "projectStateCloudVO";
    public static final String PK_PROJECT_TYPE = "pkProjectType";
    public static final String PK_PROJECT_STATUS = "pkProjectStatus";
    public static final String CREATOR = "creator";
    public static final String CREATOR_NAME = "creatorName";
    public static final String ORG_NAME = "orgName";

    public static final String PROCEDURES = "procedures";
    public static final String ADDRESS = "address";
    public static final String LONGITUDE = "longitude";
    public static final String LATITUDE = "latitude";

    public static final String PREWORKRESUME_DATE = "preworkresumeDate";
    public static final String WORKSTOP_DATE = "workstopDate";

    @NotNull(groups = UpdateValid.class)
    @Size(min = CommonProgramConsts.UUID_STRING_LENGTH,
            max = CommonProgramConsts.UUID_STRING_LENGTH, groups = UpdateValid.class)
    @Id
    private String pkProject;
    private String pkTenant;
    @NotNull(groups = InsertValid.class)
    @Size(max = 50, groups = InsertValid.class)
    private String scode;
    @NotNull(groups = InsertValid.class)
    @Size(max = 300, groups = InsertValid.class)
    private String sname;
    /**
     * 项目经理
     */
    private String manager;
    @Transient
    private String managerName;
    /**
     * 立项日期
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @NotNull(groups = InsertValid.class)
    private Date approvalDate;
    /**
     * 验收日期（初始需求为"结束日期"）
     */
    private Date endDate;

    /**
     * 预计复工日期
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    private Date preworkresumeDate;

    /**
     * 停工日期
     */
    private Date workstopDate;

    /**
     * 描述
     */
    @Size(max = 300)
    private String description;
    /**
     * 项目状态：
     * -3停工 -2暂停 -1创建 0施工中 1竣工 3复工
     * @see ProjectConst
     */
    private byte projectState;
    private String creator;
    @Transient
    private String creatorName;
    private Date creationtime;
    private String modifier;
    private Date modifytime;

    /**  20180509新增字段 **/
    /**
     * 组织字段：目前只有NC集成时，推送生成
     */
    private String pkOrg;
    /**
     * 档案来源：
     *      友工程默认为空
     *      NC记为NC
     *
     */
    private String srcType;
    /**
     * 记录来源主键
     */
    private String pkSrc;
    /**
     * 项目地址
     */
    private String address;
    /**
     * 经度
     */
    private BigDecimal longitude;
    /**
     * 纬度
     */
    private BigDecimal latitude;

    /**
     * 距离
     */
    @Transient
    private double distance;

    @Transient
    private String managerMobile;

    @Transient
    private String creatorMobile;

    //重点项目标识
    private Boolean iskey;

    /** 用于统计分析展示 */
    //项目实际进度
    @Transient
    private int progress;

    //计划开始时间
    @Transient
    private Date expeStartDate;

    //计划结束时间
    @Transient
    private Date expeEndDate;

    //按时达成率
    @Transient
    private int onTimeCompletionRate;


    private String pkProjectType;

    private String pkProjectStatus;
    @Transient
    private String projectStatusName;
    @Transient
    private String orgName;

    @Transient
    private ProjectTypeVO projectTypeCloudVO;
    @Transient
    private ProjectStatusVO projectStateCloudVO;
    //关联
    @Transient
    private String[] procedures;//关联工序

    //判断该项目是否有编制计划
    @Transient
    private boolean hasPlan;
    @Transient
    private ProjectPlanViewVO[] projectPlanVOS;

    /**
     *  停工天数
     */
    @Transient
    private Integer workstopdays;

    /**
     * 累计停工天数
     */
    private Integer totworkstopDays;


    public interface UpdateValid {
    }

    public interface InsertValid {
    }

}
